home *** CD-ROM | disk | FTP | other *** search
/ QRZ! Ham Radio 1 / QRZ Ham Radio Callsign Database - December 1993.iso / ucsd / packet / tcpip / sys5 / iscwmpst.z / iscwmpst / tcp / src / config.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-10-04  |  20.4 KB  |  798 lines

  1. /* @(#) $Header: config.c,v 1.13 91/10/03 11:04:58 deyke Exp $ */
  2.  
  3. /* A collection of stuff heavily dependent on the configuration info
  4.  * in config.h. The idea is that configuration-dependent tables should
  5.  * be located here to avoid having to pepper lots of .c files with #ifdefs,
  6.  * requiring them to include config.h and be recompiled each time config.h
  7.  * is modified.
  8.  *
  9.  * Copyright 1991 Phil Karn, KA9Q
  10.  */
  11.  
  12. #include <stdio.h>
  13. /* #include <dos.h> */
  14. #include "global.h"
  15. #include "config.h"
  16. #include "mbuf.h"
  17. #include "timer.h"
  18. #include "proc.h"
  19. #include "iface.h"
  20. #include "ip.h"
  21. #include "tcp.h"
  22. #include "udp.h"
  23. #ifdef  ARCNET
  24. #include "arcnet.h"
  25. #endif
  26. #include "lapb.h"
  27. #include "ax25.h"
  28. #include "enet.h"
  29. #include "kiss.h"
  30. /* #include "nr4.h" */
  31. #include "netrom.h"
  32. #include "pktdrvr.h"
  33. /* #include "ppp.h" */
  34. #include "slip.h"
  35. #include "arp.h"
  36. #include "icmp.h"
  37. #include "hardware.h"   /***/
  38. /* #include "usock.h" */
  39. #include "cmdparse.h"
  40. #include "commands.h"
  41. /* #include "mailbox.h" */
  42. /* #include "ax25mail.h" */
  43. /* #include "nr4mail.h" */
  44. /* #include "tipmail.h" */
  45. /* #include "daemon.h" */
  46. #include "bootp.h"
  47.  
  48. static int dostart __ARGS((int argc,char *argv[],void *p));
  49. static int dostop __ARGS((int argc,char *argv[],void *p));
  50. static int dostatus __ARGS((int argc,char *argv[],void *p));
  51.  
  52. #ifdef  AX25
  53. static void axip __ARGS((struct iface *iface,struct ax25_cb *axp,char *src,
  54.     char *dest,struct mbuf *bp,int mcast));
  55. static void axarp __ARGS((struct iface *iface,struct ax25_cb *axp,char *src,
  56.     char *dest,struct mbuf *bp,int mcast));
  57. static void axnr __ARGS((struct iface *iface,struct ax25_cb *axp,char *src,
  58.     char *dest,struct mbuf *bp,int mcast));
  59. #endif
  60.  
  61. struct mbuf *Hopper;
  62. unsigned Nsessions = NSESSIONS;
  63. int Shortstatus;
  64.  
  65. /* Free memory threshold, below which things start to happen to conserve
  66.  * memory, like garbage collection, source quenching and refusing connects
  67.  */
  68. int32 Memthresh = MTHRESH;
  69.  
  70. /* Transport protocols atop IP */
  71. struct iplink Iplink[] = {
  72.     TCP_PTCL,       tcp_input,
  73.     UDP_PTCL,       udp_input,
  74.     ICMP_PTCL,      icmp_input,
  75.     IP_PTCL,        ipip_recv,
  76.     0,              0
  77. };
  78.  
  79. /* Transport protocols atop ICMP */
  80. struct icmplink Icmplink[] = {
  81.     TCP_PTCL,       tcp_icmp,
  82.     0,              0
  83. };
  84.  
  85. /* ARP protocol linkages */
  86. struct arp_type Arp_type[NHWTYPES] = {
  87. #ifdef  NETROM
  88.     AXALEN, 0, 0, 0, NULLCHAR, pax25, setcall,      /* ARP_NETROM */
  89. #else
  90.     0, 0, 0, 0, NULLCHAR,NULL,NULL,
  91. #endif
  92.  
  93. #ifdef  ETHER
  94.     EADDR_LEN,IP_TYPE,ARP_TYPE,1,Ether_bdcst,pether,gether, /* ARP_ETHER */
  95. #else
  96.     0, 0, 0, 0, NULLCHAR,NULL,NULL,
  97. #endif
  98.  
  99.     0, 0, 0, 0, NULLCHAR,NULL,NULL,                 /* ARP_EETHER */
  100.  
  101. #ifdef  AX25
  102.     AXALEN, PID_IP, PID_ARP, 10, Ax25_bdcst, pax25, setcall,
  103. #else
  104.     0, 0, 0, 0, NULLCHAR,NULL,NULL,                 /* ARP_AX25 */
  105. #endif
  106.  
  107.     0, 0, 0, 0, NULLCHAR,NULL,NULL,                 /* ARP_PRONET */
  108.  
  109.     0, 0, 0, 0, NULLCHAR,NULL,NULL,                 /* ARP_CHAOS */
  110.  
  111.     0, 0, 0, 0, NULLCHAR,NULL,NULL,                 /* ARP_IEEE802 */
  112.  
  113. #ifdef  ARCNET
  114.     AADDR_LEN, ARC_IP, ARC_ARP, 1, ARC_bdcst, parc, garc, /* ARP_ARCNET */
  115. #else
  116.     0, 0, 0, 0, NULLCHAR,NULL,NULL,
  117. #endif
  118.  
  119.     0, 0, 0, 0, NULLCHAR,NULL,NULL,                 /* ARP_APPLETALK */
  120. };
  121.  
  122. #ifdef  AX25
  123. /* Linkage to network protocols atop ax25 */
  124. struct axlink Axlink[] = {
  125.     PID_IP,         axip,
  126.     PID_ARP,        axarp,
  127. #ifdef  NETROM
  128.     PID_NETROM,     axnr,
  129. #endif
  130.     PID_NO_L3,      axnl3,
  131.     0,              NULL,
  132. };
  133.  
  134. /* List of AX.25 multicast addresses */
  135. char *Axmulti[] = {
  136.     Ax25_bdcst,
  137. #ifdef  NETROM
  138.     Nr_nodebc,
  139. #endif
  140.     NULLCHAR,
  141. };
  142. #endif
  143.  
  144. #if     0
  145. void (*Listusers) __ARGS((int s)) = listusers;
  146. #else
  147. void (*Listusers) __ARGS((int s)) = NULL;
  148. #endif
  149.  
  150. #ifndef BOOTP
  151. int WantBootp = 0;
  152.  
  153. int
  154. bootp_validPacket(ip,bpp)
  155. struct ip *ip;
  156. struct mbuf **bpp;
  157. {
  158.     return 0;
  159. }
  160. #endif
  161.  
  162. struct iftype Iftypes[] = {
  163.     /* This entry must be first, since Loopback refers to it */
  164.     "None",         NULL,           NULL,           NULL,
  165.     NULL,           CL_NONE,        0,
  166.  
  167. #ifdef  AX25
  168.     "AX25",         ax_send,        ax_output,      pax25,
  169.     setcall,        CL_AX25,        AXALEN,
  170. #endif
  171.  
  172. #ifdef  SLIP
  173.     "SLIP",         slip_send,      NULL,           NULL,
  174.     NULL,           CL_NONE,        0,
  175. #endif
  176.  
  177. #ifdef  ETHER
  178.     /* Note: NULL is specified for the scan function even though
  179.      * gether() exists because the packet drivers don't support
  180.      * address setting.
  181.      */
  182.     "Ethernet",     enet_send,      enet_output,    pether,
  183.     NULL,           CL_ETHERNET,    EADDR_LEN,
  184. #endif
  185.  
  186. #ifdef  NETROM
  187.     "NETROM",       nr_send,        NULL,           pax25,
  188.     setcall,        CL_NETROM,      AXALEN,
  189. #endif
  190.  
  191. #ifdef  SLFP
  192.     "SLFP",         pk_send,        NULL,           NULL,
  193.     NULL,           CL_NONE,        0,
  194. #endif
  195.  
  196. #ifdef  PPP
  197.     "PPP",          ppp_send,       ppp_output,     NULL,
  198.     NULL,           CL_PPP, 0,
  199. #endif
  200.  
  201.     NULLCHAR
  202. };
  203.  
  204. /* Command lookup and branch tables */
  205. struct cmds Cmds[] = {
  206.     /* The "go" command must be first */
  207.     "",             go,             0, 0, NULLCHAR,
  208. #ifndef AMIGA
  209.     "!",            doshell,        0, 0, NULLCHAR,
  210. #endif
  211. /*      "abort",        doabort,        0, 0, NULLCHAR, */
  212. #ifdef  AMIGA
  213.     "amiga",        doamiga,        0, 0, NULLCHAR,
  214. #endif
  215. #if     (defined(MAC) && defined(APPLETALK))
  216.     "applestat",    doatstat,       0,      0, NULLCHAR,
  217. #endif
  218. #if     (defined(AX25) || defined(ETHER) || defined(APPLETALK))
  219.     "arp",          doarp,          0, 0, NULLCHAR,
  220. #endif
  221. #ifdef  ASY
  222.     "asystat",      doasystat,      0, 0, NULLCHAR,
  223. #endif
  224.     "attach",       doattach,       0, 2,
  225.         "attach <hardware> <hw specific options>",
  226. #ifdef  AX25
  227.     "ax25",         doax25,         0, 0, NULLCHAR,
  228.     "axip",         doaxip,         0, 0, NULLCHAR,
  229. #endif
  230. #ifdef  BOOTP
  231.     "bootp",        dobootp,        0, 0, NULLCHAR,
  232.     "bootpd",       bootpdcmd,      0, 0, NULLCHAR,
  233. #endif
  234.     "bye",          dobye,          0, 0, NULLCHAR,
  235. /* This one is out of alpabetical order to allow abbreviation to "c" */
  236. #ifdef  AX25
  237.     "connect",      doconnect,      1024, 2,
  238.     "connect callsign [digipeaters]",
  239. #endif
  240. #if     !defined(UNIX) && !defined(AMIGA)
  241.     "cd",           docd,           0, 0, NULLCHAR,
  242. #endif
  243.     "close",        doclose,        0, 0, NULLCHAR,
  244. /* This one is out of alpabetical order to allow abbreviation to "d" */
  245.     "disconnect",   doclose,        0, 0, NULLCHAR,
  246.     "delete",       dodelete,       0, 2, "delete <file>",
  247. /*      "detach",       dodetach,       0, 2, "detach <interface>", */
  248. #ifdef  DIALER
  249.     "dialer",       dodialer,       512, 3,
  250.     "dialer <iface> [<file> [<seconds> [<pings> [<hostid>]]]]",
  251. #endif
  252. #ifndef AMIGA
  253. /*      "dir",          dodir,          512, 0, NULLCHAR, /* note sequence */
  254. #endif
  255.     "domain",       dodomain,       0, 0, NULLCHAR,
  256. #ifdef  DRSI
  257.     "drsistat",     dodrstat,       0, 0, NULLCHAR,
  258. #endif
  259. #ifdef  EAGLE
  260.     "eaglestat",    doegstat,       0, 0, NULLCHAR,
  261. #endif
  262.     "echo",         doecho,         0, 0, NULLCHAR,
  263.     "eol",          doeol,          0, 0, NULLCHAR,
  264. #if     !defined(MSDOS)
  265.     "escape",       doescape,       0, 0, NULLCHAR,
  266. #endif
  267. #ifdef  PC_EC
  268.     "etherstat",    doetherstat,    0, 0, NULLCHAR,
  269. #endif
  270.     "exit",         doexit,         0, 0, NULLCHAR,
  271.     "finger",       dofinger,       1024, 2, "finger name@host",
  272.     "fkey",         dofkey,         0, 3, "fkey <key#> <text>",
  273.     "ftp",          doftp,          2048, 2, "ftp <address>",
  274. #ifdef HAPN
  275.     "hapnstat",     dohapnstat,     0, 0, NULLCHAR,
  276. #endif
  277. /*      "help",         dohelp,         0, 0, NULLCHAR, */
  278. #ifdef  HOPCHECK
  279.     "hop",          dohop,          0, 0, NULLCHAR,
  280. #endif
  281.     "hostname",     dohostname,     0, 0, NULLCHAR,
  282. #ifdef  HS
  283.     "hs",           dohs,           0, 0, NULLCHAR,
  284. #endif
  285.     "icmp",         doicmp,         0, 0, NULLCHAR,
  286.     "ifconfig",     doifconfig,     0, 0, NULLCHAR,
  287.     "ip",           doip,           0, 0, NULLCHAR,
  288. #ifdef  MSDOS
  289.     "isat",         doisat,         0, 0, NULLCHAR,
  290. #endif
  291.     "kick",         dokick,         0, 0, NULLCHAR,
  292.     "log",          dolog,          0, 0, NULLCHAR,
  293. #ifdef  MAILBOX
  294. /*      "mbox",         dombox,         0, 0, NULLCHAR, */
  295. #endif
  296. #if     1
  297.     "memory",       domem,          0, 0, NULLCHAR,
  298. #endif
  299.     "mkdir",        domkd,          0, 2, "mkdir <directory>",
  300. #ifdef  AX25
  301.     "mode",         domode,         0, 2, "mode <interface>",
  302. #endif
  303. /*      "more",         domore,         512, 2, "more <filename>", */
  304. #ifdef  NETROM
  305.     "netrom",       donetrom,       0, 0, NULLCHAR,
  306. #endif  /* NETROM */
  307. #ifdef  NNTP
  308.     "nntp",         donntp,         0, 0, NULLCHAR,
  309. #endif  /* NNTP */
  310. #ifdef  NRS
  311.     "nrstat",       donrstat,       0, 0, NULLCHAR,
  312. #endif  /* NRS */
  313.     "param",        doparam,        0, 2, "param <interface>",
  314.     "ping",         doping,         512, 0,
  315.     NULLCHAR,
  316. #ifdef  PI
  317.     "pistatus",     dopistat,       0, 0, NULLCHAR,
  318. #endif
  319. #ifdef POP
  320.     "pop",          dopop,          0, 0, NULLCHAR,
  321. #endif
  322. #ifdef PPP
  323.     "ppp",          doppp_commands, 0, 0, NULLCHAR,
  324. #endif
  325. /*      "ps",           ps,             0, 0, NULLCHAR, */
  326. #if     !defined(UNIX) && !defined(AMIGA)
  327.     "pwd",          docd,           0, 0, NULLCHAR,
  328. #endif
  329.     "record",       dorecord,       0, 0, NULLCHAR,
  330.     "remote",       doremote,       0, 3, "remote [-p port] [-k key] [-a kickaddr] <address> exit|reset|kick",
  331.     "rename",       dorename,       0, 3, "rename <oldfile> <newfile>",
  332.     "reset",        doreset,        0, 0, NULLCHAR,
  333. #ifdef  RIP
  334.     "rip",          dorip,          0, 0, NULLCHAR,
  335. #endif
  336.     "rmdir",        dormd,          0, 2, "rmdir <directory>",
  337.     "route",        doroute,        0, 0, NULLCHAR,
  338.     "rtprio",       dortprio,       0, 0, NULLCHAR,
  339.     "session",      dosession,      0, 0, NULLCHAR,
  340.     "status",       dostatus,       0, 0, NULLCHAR,
  341. #ifdef  SCC
  342.     "sccstat",      dosccstat,      0, 0, NULLCHAR,
  343. #endif
  344. #if     !defined(AMIGA)
  345.     "shell",        doshell,        0, 0, NULLCHAR,
  346. #endif
  347.     "smtp",         dosmtp,         0, 0, NULLCHAR,
  348. /*      "socket",       dosock,         0, 0, NULLCHAR, */
  349.     "source",       dosource,       0, 2, "source <filename>",
  350. #ifdef  SERVERS
  351.     "start",        dostart,        0, 2, "start <servername>",
  352.     "stop",         dostop,         0, 2, "stop <servername>",
  353. #endif
  354.     "stime",        dostime,        0, 0, NULLCHAR,
  355.     "tcp",          dotcp,          0, 0, NULLCHAR,
  356.     "telnet",       dotelnet,       1024, 2, "telnet <address>",
  357. /*      "tip",          dotip,          256, 2, "tip <iface", */
  358. #ifdef  TRACE
  359.     "trace",        dotrace,        0, 0, NULLCHAR,
  360. #endif
  361.     "udp",          doudp,          0, 0, NULLCHAR,
  362.     "upload",       doupload,       0, 0, NULLCHAR,
  363. #ifdef  MSDOS
  364.     "watch",        doswatch,       0, 0, NULLCHAR,
  365. #endif
  366. /*      "?",            dohelp,         0, 0, NULLCHAR, */
  367.     NULLCHAR,       NULLFP,         0, 0,
  368.         "Unknown command; type \"?\" for list",
  369. };
  370.  
  371. /* List of supported hardware devices */
  372. struct cmds Attab[] = {
  373. #ifdef  PC_EC
  374.     /* 3-Com Ethernet interface */
  375.     "3c500", ec_attach, 0, 7,
  376.     "attach 3c500 <address> <vector> arpa <label> <buffers> <mtu> [ip_addr]",
  377. #endif
  378. #ifdef  ASY
  379.     /* Ordinary PC asynchronous adaptor */
  380.     "asy", asy_attach, 0, 8,
  381. #ifndef AMIGA
  382.     "attach asy <address> <vector> slip|ax25|nrs <label> <buffers> <mtu> <speed> [ip_addr]",
  383. #else
  384.     "attach asy <driver> <unit> slip|ax25|nrs <label> <buffers> <mtu> <speed> [ip_addr]",
  385. #endif  /* AMIGA */
  386. #endif  /* ASY */
  387. #ifdef  PC100
  388.     /* PACCOMM PC-100 8530 HDLC adaptor */
  389.     "pc100", pc_attach, 0, 8,
  390.     "attach pc100 <address> <vector> ax25 <label> <buffers>\
  391.  <mtu> <speed> [ip_addra] [ip_addrb]",
  392. #endif
  393. #ifdef  DRSI
  394.     /* DRSI PCPA card in low speed mode */
  395.     "drsi", dr_attach, 0, 8,
  396.     "attach drsi <address> <vector> ax25 <label> <bufsize> <mtu>\
  397. <chan a speed> <chan b speed> [ip addr a] [ip addr b]",
  398. #endif
  399. #ifdef  EAGLE
  400.     /* EAGLE RS-232C 8530 HDLC adaptor */
  401.     "eagle", eg_attach, 0, 8,
  402.     "attach eagle <address> <vector> ax25 <label> <buffers>\
  403.  <mtu> <speed> [ip_addra] [ip_addrb]",
  404. #endif
  405. #ifdef  PI
  406.     /* PI 8530 HDLC adaptor */
  407.     "pi", pi_attach, 0, 8,
  408.     "attach pi <address> <vector> <dmachannel> ax25 <label> <buffers>\
  409.  <mtu> <speed> [ip_addra] [ip_addrb]",
  410. #endif
  411. #ifdef  HAPN
  412.     /* Hamilton Area Packet Radio (HAPN) 8273 HDLC adaptor */
  413.     "hapn", hapn_attach, 0, 8,
  414.     "attach hapn <address> <vector> ax25 <label> <rx bufsize>\
  415.  <mtu> csma|full [ip_addr]",
  416. #endif
  417. #ifdef  APPLETALK
  418.     /* Macintosh AppleTalk */
  419.     "0", at_attach, 0, 7,
  420.     "attach 0 <protocol type> <device> arpa <label> <rx bufsize> <mtu> [ip_addr]",
  421. #endif
  422. #ifdef NETROM
  423.     /* fake netrom interface */
  424.     "netrom", nr_attach, 0, 1,
  425.     "attach netrom [ip_addr]",
  426. #endif
  427. #ifdef  PACKET
  428.     /* FTP Software's packet driver spec */
  429.     "packet", pk_attach, 0, 4,
  430.     "attach packet <int#> <label> <buffers> <mtu> [ip_addr]",
  431. #endif
  432. #ifdef  HS
  433.     /* Special high speed driver for DRSI PCPA or Eagle cards */
  434.     "hs", hs_attach, 0, 7,
  435.     "attach hs <address> <vector> ax25 <label> <buffers> <mtu>\
  436.  <txdelay> <persistence> [ip_addra] [ip_addrb]",
  437. #endif
  438. #ifdef SCC
  439.     "scc", scc_attach, 0, 7,
  440.     "attach scc <devices> init <addr> <spacing> <Aoff> <Boff> <Dataoff>\n"
  441.     "   <intack> <vec> [p]<clock> [hdwe] [param]\n"
  442.     "attach scc <chan> slip|kiss|nrs|ax25 <label> <mtu> <speed> <bufsize> [call] ",
  443. #endif
  444. #ifdef  AX25
  445.     "axip", axip_attach, 0, 1,
  446.     "attach axip",
  447. #endif
  448.     NULLCHAR,
  449. };
  450.  
  451. /* Packet tracing stuff */
  452. #ifdef  TRACE
  453. #include "trace.h"
  454.  
  455. /* Protocol tracing function pointers. Matches list of class definitions
  456.  * in pktdrvr.h.
  457.  */
  458. struct trace Tracef[] = {
  459.     NULLFP,         ip_dump,        /* CL_NONE */
  460.  
  461. #ifdef  ETHER                           /* CL_ETHERNET */
  462.     ether_forus,    ether_dump,
  463. #else
  464.     NULLFP,         NULLVFP,
  465. #endif  /* ETHER */
  466.  
  467.     NULLFP,         NULLVFP,        /* CL_PRONET_10 */
  468.     NULLFP,         NULLVFP,        /* CL_IEEE8025 */
  469.     NULLFP,         NULLVFP,        /* CL_OMNINET */
  470.  
  471. #ifdef  APPLETALK
  472.     at_forus,       at_dump,        /* CL_APPLETALK */
  473. #else
  474.     NULLFP,         NULLVFP,
  475. #endif  /* APPLETALK */
  476.  
  477. #ifdef VJCOMPRESS
  478.     NULLFP,         sl_dump,        /* CL_SERIAL_LINE */
  479. #else
  480.     NULLFP,         ip_dump,        /* CL_SERIAL_LINE */
  481. #endif
  482.     NULLFP,         NULLVFP,        /* CL_STARLAN */
  483.  
  484. #ifdef  ARCNET
  485.     arc_forus,      arc_dump,       /* CL_ARCNET */
  486. #else
  487.     NULLFP,         NULLVFP,
  488. #endif  /* ARCNET */
  489.  
  490. #ifdef  AX25
  491.     ax_forus,       ax25_dump,      /* CL_AX25 */
  492. #else
  493.     NULLFP,         NULLVFP,
  494. #endif  /* AX25 */
  495.  
  496. #ifdef  KISS                            /* CL_KISS */
  497.     ki_forus,       ki_dump,
  498. #else
  499.     NULLFP,         NULLVFP,
  500. #endif  /* KISS */
  501.  
  502.     NULLFP,         NULLVFP,        /* CL_IEEE8023 */
  503.     NULLFP,         NULLVFP,        /* CL_FDDI */
  504.     NULLFP,         NULLVFP,        /* CL_INTERNET_X25 */
  505.     NULLFP,         NULLVFP,        /* CL_LANSTAR */
  506.     NULLFP,         ip_dump,        /* CL_SLFP */
  507.  
  508. #ifdef  NETROM                          /* CL_NETROM */
  509.     NULLFP,         ip_dump,
  510. #else
  511.     NULLFP,         NULLVFP,
  512. #endif
  513.  
  514. #ifdef PPP
  515.     NULLFP,         ppp_dump,       /* CL_PPP */
  516. #else
  517.     NULLFP,         NULLVFP,
  518. #endif /* PPP */
  519. };
  520.  
  521. #else   /* TRACE */
  522.  
  523. /* Stub for packet dump function */
  524. void
  525. dump(iface,direction,type,bp)
  526. struct iface *iface;
  527. int direction;
  528. unsigned type;
  529. struct mbuf *bp;
  530. {
  531. }
  532. void
  533. raw_dump(iface,direction,bp)
  534. struct iface *iface;
  535. int direction;
  536. struct mbuf *bp;
  537. {
  538. }
  539.  
  540. #endif  /* TRACE */
  541.  
  542. #ifdef  AX25
  543. /* Hooks for passing incoming AX.25 data frames to network protocols */
  544. static void
  545. axip(iface,axp,src,dest,bp,mcast)
  546. struct iface *iface;
  547. struct ax25_cb *axp;
  548. char *src;
  549. char *dest;
  550. struct mbuf *bp;
  551. int mcast;
  552. {
  553.     if (bp && bp->cnt >= 20)
  554.         arp_add(get32(bp->data + 12), ARP_AX25, src, 0);
  555.     (void)ip_route(iface,bp,mcast);
  556. }
  557.  
  558. static void
  559. axarp(iface,axp,src,dest,bp,mcast)
  560. struct iface *iface;
  561. struct ax25_cb *axp;
  562. char *src;
  563. char *dest;
  564. struct mbuf *bp;
  565. int mcast;
  566. {
  567.     (void)arp_input(iface,bp);
  568. }
  569.  
  570. #ifdef  NETROM
  571. static void
  572. axnr(iface,axp,src,dest,bp,mcast)
  573. struct iface *iface;
  574. struct ax25_cb *axp;
  575. char *src;
  576. char *dest;
  577. struct mbuf *bp;
  578. int mcast;
  579. {
  580.     nr3_input(bp, src);
  581. }
  582.  
  583. #endif  /* NETROM */
  584. #endif  /* AX25 */
  585.  
  586. #ifndef RIP
  587. /* Stub for routing timeout when RIP is not configured -- just remove entry */
  588. void
  589. rt_timeout(s)
  590. void *s;
  591. {
  592.     struct route *stale = (struct route *)s;
  593.  
  594.     rt_drop(stale->target,stale->bits);
  595. }
  596. #endif
  597.  
  598. #ifdef  SERVERS
  599. /* "start" and "stop" subcommands */
  600. static struct cmds Startcmds[] = {
  601. #if     defined(AX25) && defined(MAILBOX)
  602.     "ax25",         ax25start,      256, 0, NULLCHAR,
  603. #endif
  604.     "discard",      dis1,           256, 0, NULLCHAR,
  605.     "echo",         echo1,          256, 0, NULLCHAR,
  606. /*      "finger",       finstart,       256, 0, NULLCHAR, */
  607.     "ftp",          ftpstart,       256, 0, NULLCHAR,
  608.     "tcpgate",      tcpgate1,       256, 2, "start tcpgate <tcp port> [<host:service>]",
  609. #if     defined(NETROM) && defined(MAILBOX)
  610.     "netrom",       nr4start,       256, 0, NULLCHAR,
  611. #endif
  612. #ifdef POP
  613.     "pop",          pop1,           256, 0, NULLCHAR,
  614. #endif
  615. #ifdef  RIP
  616.     "rip",          doripinit,      0,   0, NULLCHAR,
  617. #endif
  618. /*      "smtp",         smtp1,          256, 0, NULLCHAR, */
  619. #if     defined(MAILBOX)
  620.     "telnet",       telnet1,        256, 0, NULLCHAR,
  621. /*      "tip",          tipstart,       256, 2, "start tip <interface>", */
  622. #endif
  623. /*      "ttylink",      ttylstart,      256, 0, NULLCHAR, */
  624.     "remote",       rem1,           768, 0, NULLCHAR,
  625.     NULLCHAR,
  626. };
  627. static struct cmds Stopcmds[] = {
  628. #if     defined(AX25) && defined(MAILBOX)
  629.     "ax25",         ax250,          0, 0, NULLCHAR,
  630. #endif
  631.     "discard",      dis0,           0, 0, NULLCHAR,
  632.     "echo",         echo0,          0, 0, NULLCHAR,
  633. /*      "finger",       fin0,           0, 0, NULLCHAR, */
  634.     "ftp",          ftp0,           0, 0, NULLCHAR,
  635. #if     defined(NETROM) && defined(MAILBOX)
  636.     "netrom",       nr40,           0, 0, NULLCHAR,
  637. #endif
  638. #ifdef  POP
  639.     "pop",          pop0,           0, 0, NULLCHAR,
  640. #endif
  641. #ifdef  RIP
  642.     "rip",          doripstop,      0, 0, NULLCHAR,
  643. #endif
  644. /*      "smtp",         smtp0,          0, 0, NULLCHAR, */
  645. #ifdef  MAILBOX
  646.     "telnet",       telnet0,        0, 0, NULLCHAR,
  647. /*      "tip",          tip0,           0, 2, "stop tip <interface>", */
  648. #endif
  649. /*      "ttylink",      ttyl0,          0, 0, NULLCHAR, */
  650.     "remote",       rem0,           0, 0, NULLCHAR,
  651.     NULLCHAR,
  652.  
  653. };
  654. static int
  655. dostart(argc,argv,p)
  656. int argc;
  657. char *argv[];
  658. void *p;
  659. {
  660.     return subcmd(Startcmds,argc,argv,p);
  661. }
  662. static int
  663. dostop(argc,argv,p)
  664. int argc;
  665. char *argv[];
  666. void *p;
  667. {
  668.     return subcmd(Stopcmds,argc,argv,p);
  669. }
  670. static int
  671. dostatus(argc,argv,p)
  672. int argc;
  673. char *argv[];
  674. void *p;
  675. {
  676.   char *my_argv[3];
  677.  
  678.   Shortstatus = 1;
  679.   my_argv[1] = "status";
  680.   my_argv[2] = NULLCHAR;
  681.  
  682. #ifdef  AX25
  683.   puts("------------------------------------ AX.25 ------------------------------------");
  684.   my_argv[0] = "ax25";
  685.   doax25(2, my_argv, p);
  686. #endif
  687.  
  688. #ifdef  NETROM
  689.   puts("------------------------------------ NETROM -----------------------------------");
  690.   my_argv[0] = "netrom";
  691.   donetrom(2, my_argv, p);
  692. #endif
  693.  
  694.   puts("------------------------------------- TCP -------------------------------------");
  695.   my_argv[0] = "tcp";
  696.   dotcp(2, my_argv, p);
  697.  
  698.   puts("------------------------------------- UDP -------------------------------------");
  699.   my_argv[0] = "udp";
  700.   doudp(2, my_argv, p);
  701.  
  702.   Shortstatus = 0;
  703.   return 0;
  704. }
  705. #endif  /* SERVERS */
  706.  
  707. /* Various configuration-dependent functions */
  708.  
  709. /* put mbuf into Hopper for network task
  710.  * returns 0 if OK
  711.  */
  712. int
  713. net_route(ifp, type, bp)
  714. struct iface *ifp;
  715. int type;
  716. struct mbuf *bp;
  717. {
  718.     struct mbuf *nbp;
  719.     struct phdr phdr;
  720.  
  721.     phdr.iface = ifp;
  722.     phdr.type = type;
  723.  
  724.     if ((nbp = pushdown(bp,sizeof(phdr))) == NULLBUF ){
  725.         return -1;
  726.     }
  727.     memcpy( &nbp->data[0],(char *)&phdr,sizeof(phdr));
  728.     enqueue(&Hopper,nbp);
  729.     /* Especially on slow machines, serial I/O can be quite
  730.      * compute intensive, so release the machine before we
  731.      * do the next packet.  This will allow this packet to
  732.      * go on toward its ultimate destination. [Karn]
  733.      */
  734. /*      pwait(NULL); */
  735.     return 0;
  736. }
  737.  
  738. /* Process packets in the Hopper */
  739. void
  740. network()
  741. {
  742.     struct mbuf *bp;
  743.     struct phdr phdr;
  744.  
  745.     /* Process the input packet */
  746.     bp = dequeue(&Hopper);
  747.     pullup(&bp,(char *)&phdr,sizeof(phdr));
  748.     if(phdr.iface != NULLIF){
  749.         phdr.iface->rawrecvcnt++;
  750.         phdr.iface->lastrecv = secclock();
  751.     }
  752.     dump(phdr.iface,IF_TRACE_IN,phdr.type,bp);
  753.     switch(phdr.type){
  754. #ifdef  KISS
  755.     case CL_KISS:
  756.         kiss_recv(phdr.iface,bp);
  757.         break;
  758. #endif
  759. #ifdef  AX25
  760.     case CL_AX25:
  761.         ax_recv(phdr.iface,bp);
  762.         break;
  763. #endif
  764. #ifdef  ETHER
  765.     case CL_ETHERNET:
  766.         eproc(phdr.iface,bp);
  767.         break;
  768. #endif
  769. #ifdef ARCNET
  770.     case CL_ARCNET:
  771.         aproc(phdr.iface,bp);
  772.         break;
  773. #endif
  774. #ifdef PPP
  775.     case CL_PPP:
  776.         ppp_proc(phdr.iface,bp);
  777.         break;
  778. #endif
  779.     /* These types have no link layer protocol at the point when they're
  780.      * put in the hopper, so they can be handed directly to IP. The
  781.      * separate types are just for user convenience when running the
  782.      * "iface" command.
  783.      */
  784.     case CL_NONE:
  785.     case CL_SERIAL_LINE:
  786.     case CL_SLFP:
  787.         ip_route(phdr.iface,bp,0);
  788.         break;
  789.     default:
  790.         free_p(bp);
  791.         break;
  792.     }
  793.     /* Let everything else run - this keeps the system from wedging
  794.      * when we're hit by a big burst of packets
  795.      */
  796. /*      pwait(NULL); */
  797. }
  798.